var api = require("../../../../api.js"),
  app = getApp();
Page({
  data: {
    userAdvise:{
      value: "",
      cursor: 0
    },
    message:'',
  },
  userInput: function(e){
    let _value = e.detail.value;
    let _cursor = e.detail.cursor;
    this.setData({
      userAdvise: {
        value: _value,
        cursor: _cursor
      }
    });
  },
  message: function(){
    var that = this;
    var message = that.data.userAdvise.value;
    if (!message){
      wx.showToast({
        title: '反馈意见不能为空',
        icon: 'none',
        duration: 1000,
      })
      return false;
    } else if (message.length < 5){
      wx.showToast({
        title: '反馈意见不能小于5个字',
        icon: 'none',
        duration: 1000,
      })
      return false;
    }
    app.request({
      url: api.user.message,
      data: {
        uid: wx.getStorageSync('uid'),
        bid: wx.getStorageSync('bid'),
        message: that.data.userAdvise.value,
      },
      success: function (e) {
        if(e == 1){
          wx.showToast({
            title: '反馈成功',
            icon: 'succes',
            duration: 1000,
            mask: true,
          })
          setTimeout(function () {
            wx.hideLoading()
            wx.navigateBack({
              url: "../user/index"
            })
          }, 1000)
        }else{
          wx.showToast({
            title: '失败',
            icon: 'none',
            duration: 1000,
            mask: false
          })
        }
      }
    })
  }
})